package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
 * 文件复制
 */
public class CopyDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("girl.jpg");
        FileOutputStream fos = new FileOutputStream("girls.jpg");

        int d ;//记录每次从源文件中读取的字节
        /*
            girl.jpg内容:
            10011001 11110000 00001111 01010101 10101010 ...
            ^^^^^^^^

            d = fis.read()
            d:00000000 00000000 00000000 10011001
            fos.write(d)

            girls.jpg内容:
            10011001

         */
        long start = System.currentTimeMillis();
        while ((d = fis.read()) != -1) {
            fos.write(d);
        }
        System.out.println("操作完成");
        fis.close();
        fos.close();
        long a = Long.MAX_VALUE;
        long end = System.currentTimeMillis();
        System.out.println("用时:" + (end - start) + "ms"+end);
        System.out.println(a/end);
    }
}
